import {computed} from 'vue';
// 添加地块的阴影
export const CityLayer = (map,adcode='420100',num) => {
    const fallColor = computed(()=>{
        if(num <= 5){
            return 'rgba(0, 128, 0,0.8)'
        }else if(num >5 && num <=10){
            return '#e57631'
        }else {
            return 'red'
        }
    })

    let style = new ol.style.Style({
        fill: new ol.style.Fill({
            color:fallColor.value
        }),
        stroke: new ol.style.Stroke({
            color: "#ff2d51",
            width: 2
        })
    })


    let source = new ol.source.Vector({
        url : `https://geo.datav.aliyun.com/areas_v3/bound/${adcode}.json`,
        format: new ol.format.GeoJSON()//解析geojson数据
    })
    let layer = new ol.layer.Vector({
        source,
        style
    })
   const layers = map.getLayers();
    layers.insertAt(2,layer); 
    // map.addLayer(layer)
}